/**
	SUNNY Project, Anyang Normal University, IMP-CAS
	\class TAMBSDList
	\brief A list to store many-body Slater determinants, classified by M, which is
	the 3rd component jz of the total angular momentum. So M is the same for each
	member of this list.
	\author SUN Yazhou
	\since 2020/01/31
	\date Last modified: 2022/12/05 by SUN Yazhou
	\copyright 2020-2023 SUN Yazhou
	\copyright SUNNY project, Anyang Normal University, IMP-CAS
*/

#ifndef _TAMBSDList_h_
#define _TAMBSDList_h_

#include <vector>
#include "TAMBSDTree.h"
#include "TAMBSD.h"

class TASPState;

using std::vector;

class TAMBSDList{
public:
	TAMBSDList();
	virtual ~TAMBSDList();

	TAMBSDTree *GetMBSDTree(){ return fMBSDTree; }
	bool MBSDFilter(ull bit) const; ///< filter mbsds
	void Add(ull bit);
	void Add(int *spsArr, int nParticle);
	void Print();
	void PrintInBit(); ///< Print all the mbsd-s in bit mode
	ull GetNBasis() const;
	ull Bit(ull mbsdIndex);
	ull operator[](ull mbsdIndex){ return Bit(mbsdIndex); }
	TASPState *GetSPState(ull mbsdIndex, int i);
	void Save(){ fMBSDTree->Save(); } ///< save the many-body state tree

	/// \retval <rr|a+_p * a_q|cc>, 1N force
	int Integral(int rr, int p, int q, int cc);
	/// \retval <rr|a+_p*a+_q * a_s*a_r|cc>, 2N force
	int Integral(int rr, int p, int q, int s, int r, int cc);
	/// \retval <rr|a+_p*a+_q*a+_r * a_u*a_t*a_s|cc>, 3N force
	int Integral(int rr, int p, int q, int r, int u, int t, int s, int cc);

protected:
	TAMBSDTree *fMBSDTree; // the ROOT version
	vector<TAMBSD *> fMBSDVec; // the general version
};

#endif
